RedBoxChatEvent
| Kind of class: | public class |
|---|---|
| Package: | com.smartfoxserver.redbox.events |
| Inherits from: | SFSEvent |
| Dispatched by: | |
| Author: | The gotoAndPlay() Team http://www.smartfoxserver.com http://www.gotoandplay.it |
| Classpath: | com.smartfoxserver.redbox.events.RedBoxChatEvent |
| File last modified: | Monday, 25 February 2008, 11:20:38 |
RedBoxChatEvent is the class representing all events dispatched by the RedBox's AVChatManager instance.
The RedBoxChatEvent extends the SFSEvent class, which in turn extends the flash.events.Event class.
SFSEvent also provides a public property called
The RedBoxChatEvent extends the SFSEvent class, which in turn extends the flash.events.Event class.
SFSEvent also provides a public property called
params of type Object that can contain any number of parameters.Usage:
- Please refer to the specific events for usage examples and
paramsobject content.
Summary
Event handlers
- onAVConnectionInited : String
- Dispatched when the connection to Red5 server has been established.
- onAVConnectionError : String
- Dispatched when the connection to Red5 server can't be established.
- onRecipientMissing : String
- Dispatched when a chat request is sent, but the recipient is not available.
- onDuplicateRequest : String
- Dispatched when a chat request is sent, but a mutual request has already been sent by the recipient.
- onChatRequest : String
- Dispatched when an a/v chat request is received.
- onChatRefused : String
- Dispatched when an a/v chat request has been refused by the recipient.
- onChatStarted : String
- Dispatched when an a/v chat session is started, after the recipient accepted the requester's invitation.
- onChatStopped : String
- Dispatched when an a/v chat session is stopped.
Event handlers
onAVConnectionError
public static const onAVConnectionError:String = "onAVConnectionError"
(read)
Dispatched when the connection to Red5 server can't be established.
This event is dispatched when an error or special condition (like "connection closed") occurred in the flash.net.NetConnection object used internally by the AVChatManager to handle the connection to Red5.
This kind of error is always related to the Red5 server connection, so you should check if the server is running and reachable.
Also check the Red5 logs or console output for more details.
NOTE: when a connection error occurs, all the existing chat sessions (whatever their status is) are stopped.
The
This event is dispatched when an error or special condition (like "connection closed") occurred in the flash.net.NetConnection object used internally by the AVChatManager to handle the connection to Red5.
This kind of error is always related to the Red5 server connection, so you should check if the server is running and reachable.
Also check the Red5 logs or console output for more details.
NOTE: when a connection error occurs, all the existing chat sessions (whatever their status is) are stopped.
The
params object contains the following parameters. Parameters:
errorCode:
(String) the description of the error condition; check the "code" property of the NetStatusEvent.info object in the Actionscript 3 Language Reference.
Example:
- The following example shows how to handle a Red5 connection error.
avChatMan.addEventListener(RedBoxChatEvent.onAVConnectionError, onAVConnectionError) function onAVConnectionError(evt:RedBoxChatEvent):void { trace("A connection error occurred: " + evt.params.errorCode) }
onAVConnectionInited
public static const onAVConnectionInited:String = "onAVConnectionInited"
(read)
Dispatched when the connection to Red5 server has been established.
This event is dispatched after the AVChatManager is instantiated or when the AVChatManager.initAVConnection method is called.
The connection to Red5 must be available before any method related to a/v streaming is called.
No parameters are provided.
This event is dispatched after the AVChatManager is instantiated or when the AVChatManager.initAVConnection method is called.
The connection to Red5 must be available before any method related to a/v streaming is called.
No parameters are provided.
Example:
- The following example shows how to handle the "onAVConnectionInited" event.
var red5IpAddress:String = "127.0.0.1" var avChatMan:AVChatManager = new AVChatManager(smartFox, red5IpAddress) avChatMan.addEventListener(RedBoxChatEvent.onAVConnectionInited, onAVConnectionInited) function onAVConnectionInited(evt:RedBoxChatEvent):void { trace("Red5 connection established") }
See also:
onChatRefused
public static const onChatRefused:String = "onChatRefused"
(read)
Dispatched when an a/v chat request has been refused by the recipient.
The
The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the ChatSession object created by the AVChatManager instance when the request was sent.
Example:
- The following example shows how to handle a chat request refusal.
avChatMan.addEventListener(RedBoxChatEvent.onChatRefused, onChatRefused) // The recipient refuses the chat request... function onChatRefused(evt:RedBoxChatEvent):void { var chatData:ChatSession = evt.params.chatSession trace ("Chat request refused by user", chatData.mateName) // Show message and reset start/stop chat buttons states ... }
See also:
onChatRequest
public static const onChatRequest:String = "onChatRequest"
(read)
Dispatched when an a/v chat request is received.
The
The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the ChatSession object created by the AVChatManager instance when the request is received.
Example:
- The following example shows how to handle an incoming chat request.
avChatMan.addEventListener(RedBoxChatEvent.onChatRequest, onChatRequest) // Another user sends a chat request... function onChatRequest(evt:RedBoxChatEvent):void { var chatData:ChatSession = evt.params.chatSession trace ("Chat request received ->", chatData.toString()) // Enable "accept" and "decline" buttons ... }
See also:
onChatStarted
public static const onChatStarted:String = "onChatStarted"
(read)
Dispatched when an a/v chat session is started, after the recipient accepted the requester's invitation.
This event is fired on both the requester and the recipient clients.
In order to display the connected users' a/v streams, the ChatSession.myStream and ChatSession.mateStream properties should be used. These two properties are set depending on the request type and on who is the requester.
Check the following table:

The
This event is fired on both the requester and the recipient clients.
In order to display the connected users' a/v streams, the ChatSession.myStream and ChatSession.mateStream properties should be used. These two properties are set depending on the request type and on who is the requester.
Check the following table:

The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the ChatSession object created by the AVChatManager instance when the request was sent/received.
Example:
- The following example shows how to handle a chat starting.
avChatMan.addEventListener(RedBoxChatEvent.onChatStarted, onChatStarted) // I'm the recipient accepting the chat request... avChatMan.acceptChatRequest(chatSessionId) function onChatStarted(evt:RedBoxChatEvent):void { var chatData:ChatSession = evt.params.chatSession var myStream:NetStream = chatData.myStream var mateStream:NetStream = chatData.mateStream // Attach streams to Video objects on stage ... }
See also:
onChatStopped
public static const onChatStopped:String = "onChatStopped"
(read)
Dispatched when an a/v chat session is stopped.
This event is not fired on the client of the user who stopped the chat session, but only on his/her mate's client.
The
This event is not fired on the client of the user who stopped the chat session, but only on his/her mate's client.
The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the ChatSession object created by the AVChatManager instance when the request was sent/received.
Example:
- The following example shows how to handle a chat being stopped.
avChatMan.addEventListener(RedBoxChatEvent.onChatStopped, onChatStopped) avChatMan.stopChat(chatSessionId) function onChatStopped(evt:RedBoxChatEvent):void { var chatData:ChatSession = evt.params.chatSession // Detach streams from Video objects on stage ... }
See also:
onDuplicateRequest
public static const onDuplicateRequest:String = "onDuplicateRequest"
(read)
Dispatched when a chat request is sent, but a mutual request has already been sent by the recipient.
The
The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the same ChatSession object returned by the AVChatManager instance when the AVChatManager.sendChatRequest method was called.
Example:
- The following example shows how to handle the "onDuplicateRequest" event.
avChatMan.addEventListener(RedBoxChatEvent.onDuplicateRequest, onDuplicateRequest) avChatMan.sendChatRequest(AVChatManager.REQ_TYPE_SEND_RECEIVE, buddyId, true, true) function onDuplicateRequest(evt:RedBoxChatEvent):void { trace ("Request '" + evt.params.chatSession.id + "' error: a mutual request has already been sent by the recipient!") }
See also:
onRecipientMissing
public static const onRecipientMissing:String = "onRecipientMissing"
(read)
Dispatched when a chat request is sent, but the recipient is not available.
The
The
params object contains the following parameters. Parameters:
chatSession:
(ChatSession) the same ChatSession object returned by the AVChatManager instance when the AVChatManager.sendChatRequest method was called.
Example:
- The following example shows how to handle the "onRecipientMissing" event.
avChatMan.addEventListener(RedBoxChatEvent.onRecipientMissing, onRecipientMissing) avChatMan.sendChatRequest(AVChatManager.REQ_TYPE_SEND_RECEIVE, buddyId, true, true) function onRecipientMissing(evt:RedBoxChatEvent):void { trace ("Request '" + evt.params.chatSession.id + "' error: the recipient is not available!") }
See also: